package com.woniuxy.ssm.powermag.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.woniuxy.ssm.entity.DeptEntity;
import com.woniuxy.ssm.entity.RoleEntity;
import com.woniuxy.ssm.powermag.mapper.DeptMapper;
import com.woniuxy.ssm.powermag.mapper.RoleMapper;
import com.woniuxy.ssm.powermag.service.IRoleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Transactional(readOnly = true)
@Service
public class RoleServiceImpl implements IRoleService {

    @Resource
    private RoleMapper roleMapper;
    @Override
    public Page<RoleEntity> page(Integer page, Integer rows, RoleEntity roleEntity) {
        PageHelper.startPage(page,rows);
        return (Page<RoleEntity>)roleMapper.page(roleEntity);
    }
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void save(RoleEntity roleEntity) {
        roleMapper.save(roleEntity);
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public void update(RoleEntity roleEntity) {
        roleMapper.update(roleEntity);
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public void deleteById(Long aLong) {
        roleMapper.deleteById(aLong);
    }

    @Override
    public RoleEntity getById(Long aLong) {
        return roleMapper.getById(aLong);
    }
}
